home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Include / ceval.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  3.6 KB  |  123 lines

  1. #ifndef Py_CEVAL_H
  2. #define Py_CEVAL_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /* Interface to random parts in ceval.c */
  8.  
  9. DL_IMPORT(PyObject *) PyEval_CallObjectWithKeywords
  10.     Py_PROTO((PyObject *, PyObject *, PyObject *));
  11.  
  12. /* DLL-level Backwards compatibility: */
  13. #undef PyEval_CallObject
  14. DL_IMPORT(PyObject *) PyEval_CallObject Py_PROTO((PyObject *, PyObject *));
  15.  
  16. /* Inline this */
  17. #define PyEval_CallObject(func,arg) \
  18.         PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
  19.  
  20. #ifdef HAVE_STDARG_PROTOTYPES
  21. DL_IMPORT(PyObject *) PyEval_CallFunction Py_PROTO((PyObject *obj, char *format, ...));
  22. DL_IMPORT(PyObject *) PyEval_CallMethod Py_PROTO((PyObject *obj,
  23.                       char *methodname, char *format, ...));
  24. #else
  25. /* Better to have no prototypes at all for varargs functions in this case */
  26. DL_IMPORT(PyObject *) PyEval_CallFunction();
  27. DL_IMPORT(PyObject *) PyEval_CallMethod();
  28. #endif
  29.  
  30. DL_IMPORT(PyObject *) PyEval_GetBuiltins Py_PROTO((void));
  31. DL_IMPORT(PyObject *) PyEval_GetGlobals Py_PROTO((void));
  32. DL_IMPORT(PyObject *) PyEval_GetLocals Py_PROTO((void));
  33. DL_IMPORT(PyObject *) PyEval_GetOwner Py_PROTO((void));
  34. DL_IMPORT(PyObject *) PyEval_GetFrame Py_PROTO((void));
  35. DL_IMPORT(int) PyEval_GetRestricted Py_PROTO((void));
  36.  
  37. DL_IMPORT(int) Py_FlushLine Py_PROTO((void));
  38.  
  39. DL_IMPORT(int) Py_AddPendingCall Py_PROTO((int (*func) Py_PROTO((ANY *)), ANY *arg));
  40. DL_IMPORT(int) Py_MakePendingCalls Py_PROTO((void));
  41.  
  42.  
  43. /* Interface for threads.
  44.  
  45.    A module that plans to do a blocking system call (or something else
  46.    that lasts a long time and doesn't touch Python data) can allow other
  47.    threads to run as follows:
  48.  
  49.     ...preparations here...
  50.     Py_BEGIN_ALLOW_THREADS
  51.     ...blocking system call here...
  52.     Py_END_ALLOW_THREADS
  53.     ...interpret result here...
  54.  
  55.    The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
  56.    {}-surrounded block.
  57.    To leave the block in the middle (e.g., with return), you must insert
  58.    a line containing RET_SAVE before the return, e.g.
  59.  
  60.     if (...premature_exit...) {
  61.         Py_BLOCK_THREADS
  62.         PyErr_SetFromErrno(PyExc_IOError);
  63.         return NULL;
  64.     }
  65.  
  66.    An alternative is:
  67.  
  68.     Py_BLOCK_THREADS
  69.     if (...premature_exit...) {
  70.         PyErr_SetFromErrno(PyExc_IOError);
  71.         return NULL;
  72.     }
  73.     Py_UNBLOCK_THREADS
  74.  
  75.    For convenience, that the value of 'errno' is restored across
  76.    Py_END_ALLOW_THREADS and RET_SAVE.
  77.  
  78.    WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
  79.    Py_END_ALLOW_THREADS!!!
  80.  
  81.    The function PyEval_InitThreads() should be called only from
  82.    initthread() in "threadmodule.c".
  83.  
  84.    Note that not yet all candidates have been converted to use this
  85.    mechanism!
  86. */
  87.  
  88. extern DL_IMPORT(PyThreadState *) PyEval_SaveThread Py_PROTO((void));
  89. extern DL_IMPORT(void) PyEval_RestoreThread Py_PROTO((PyThreadState *));
  90.  
  91. #ifdef WITH_THREAD
  92.  
  93. extern DL_IMPORT(void) PyEval_InitThreads Py_PROTO((void));
  94. extern DL_IMPORT(void) PyEval_AcquireLock Py_PROTO((void));
  95. extern DL_IMPORT(void) PyEval_ReleaseLock Py_PROTO((void));
  96. extern DL_IMPORT(void) PyEval_AcquireThread Py_PROTO((PyThreadState *tstate));
  97. extern DL_IMPORT(void) PyEval_ReleaseThread Py_PROTO((PyThreadState *tstate));
  98.  
  99. #define Py_BEGIN_ALLOW_THREADS { \
  100.             PyThreadState *_save; \
  101.             _save = PyEval_SaveThread();
  102. #define Py_BLOCK_THREADS    PyEval_RestoreThread(_save);
  103. #define Py_UNBLOCK_THREADS    _save = PyEval_SaveThread();
  104. #define Py_END_ALLOW_THREADS    PyEval_RestoreThread(_save); \
  105.          }
  106.  
  107. #else /* !WITH_THREAD */
  108.  
  109. #define Py_BEGIN_ALLOW_THREADS {
  110. #define Py_BLOCK_THREADS
  111. #define Py_UNBLOCK_THREADS
  112. #define Py_END_ALLOW_THREADS }
  113.  
  114. #endif /* !WITH_THREAD */
  115.  
  116. extern DL_IMPORT(int) _PyEval_SliceIndex Py_PROTO((PyObject *, int *));
  117.  
  118.  
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif /* !Py_CEVAL_H */
  123.